package sixteenth_day;

/**
 * 递归实现数组的逆序打印
 */
public class ReverseOutputRecursive {
    public static void output(int[] nums, int len) {
        if (len == 1) {
            System.out.print(nums[0]);
            return;
        }
        System.out.print(nums[len - 1] + " ");
        output(nums, len - 1);
    }

    public static void main(String[] args) {
        int[] nums = new int[] {1, 2, 3, 4, 5};
        output(nums, nums.length);
    }
}
